import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    menu: []
  },
  getters: {
    menu(state) {
      return state.menu
    }
  },
  mutations: {
    SET_MENU(state, payload) {
      state.menu = payload
    }
  },
  actions: {
    async GET_MENU({ commit }) {
      const resp = await axios.get('/api/menu/list')

      commit('SET_MENU', resp.data.data)

      console.log(resp.data.data);
    }
  },
  modules: {
  }
})
